/*************************************************************************
	> File Name: P5736.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-14 10:07:17
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 100000
bool flag[MAX_N + 5] = {1, 1, 0};

void init_prime() {
    for (int i = 2; i <= MAX_N; i++) {
        if (flag[i]) continue;
        for (int j = i, I = MAX_N / i; j <= I; j++) {
            flag[i * j] = 1;
        }
    }
    return ;
}

int main() {
    init_prime();
    int n;
    cin >> n;
    for (int i = 0, x; i < n; i++) {
        cin >> x;
        if (flag[x]) continue;
        cout << x << " ";
    }
    cout << endl;
    return 0;
}
